package framework.utils.http;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Http response implementation
 *
 * @author	Orlin Tomov
 * @version	0.2
 */
public class HttpResponse extends Http {

	public HttpResponse(int maxlen) {
		super(maxlen);
	}

	/**
	 * Create the response
	 *
	 * @param	response	status
	 */
	public HttpResponse(String response) {
		add(HTTP_1_1 + " " + response);
		add("Date: " + new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z").format(new Date()));
		add(SERVER);
	}

	/**
	 * Adds content and it type
	 *
	 * @param	line	the content
	 * @param	contentType	content type
	 */
	public void addContent(String line, String contentType) {
		add(CONTENT_LENGTH + line.length());
		add(CONTENT_TYPE + contentType);
		add(CONN_CLOSE);
		add("");
		add(line);
	}

	public List<Object> getLines() {
		return lines;
	}
}
